#include "cAnnounce.h"

#include <sstream>
#include <Poco/DOM/Document.h>
#include <Poco/DOM/NodeIterator.h>
#include "misc/Interface.h"
#include "misc/Debug.h"
#include "client/Client.h"
/*********************************************************/
void cAnnounce::execute()
{
	Client& client = Client::Instance();
	client.nsAddr = Poco::Net::SocketAddress(addr);
}
/*********************************************************/
std::string cAnnounce::serialize() const
{
	Client& c = Client::Instance();
	std::ostringstream		ostr;
	id = c.getID();

	ostr << "<GS id='" << id << "'>";
	ostr << "<Announce>" << addr << "</Announce>";
	ostr << "</GS>";

	return( ostr.str() );
}
/*********************************************************/
void cAnnounce::deserialize(Poco::XML::NodeIterator& it)
{
	Poco::XML::Node* node = it.previousNode();
	addr = node->innerText();
}
/*********************************************************/
void cAnnounce::setAddress(const std::string& addr)
{
	cAnnounce::addr = addr;
}
/*********************************************************/
std::string cAnnounce::getAddress() const
{
	return addr;
}
